﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dawn_of_Man
{
    [Serializable()]
    public class Village
    {
        public bool constructed = false;
        public String name { get; set; }
        public List<Building> buildings { get; set; }
        public List<Area> areas { get; set; }
        public StorageHut storageHut { get; set; }
        public event EventHandler Changed;
        // Invoke the Changed event; called whenever list changes:
        protected virtual void OnChanged(EventArgs e)
        {
            if (Changed != null)
                Changed(this, e);
        }



        public List<Building> craftBuildings()
        {
            List<Building> craftBuildings = new List<Building>();

            foreach (Building b in buildings)
            {
                if (b.baseGoodPrTurn > 0)
                {
                    craftBuildings.Add(b);
                }
            }

            return craftBuildings;
        }

        public List<Area> surroundingAreas()
        {
            List<Area> surroundingAreas = new List<Area>();
            surroundingAreas.AddRange(areas);

            return surroundingAreas;
        }

        public List<Building> utilityBuildings()
        {
            List<Building> utilityBuildings = new List<Building>();
            foreach (Building b in buildings)
            {
                if (b.baseGoodPrTurn < 0)
                {
                    utilityBuildings.Add(b);
                }
            }
            return utilityBuildings;
        }
    }
}
